#include "Servidor.h"
#include <stdlib.h>



/**************************************************************************************/
Servidor *CrearServidor(const char *unaIP, const char *unPuerto, const char *unProtocolo)
{
    Servidor *unServidor;

	if ((unServidor=malloc(sizeof(Servidor))) == NULL)
		return NULL;

	strcpy(unServidor->ip,unaIP);
	strcpy(unServidor->puerto,unPuerto);
	strcpy(unServidor->protocolo,unProtocolo);
	
	return unServidor;
}


/**************************************************************************************/

char *GetProtocolo(const Servidor *unServidor)
{
     char* unProtocolo;
     
	if((unProtocolo=malloc(strlen(unServidor->protocolo)+1))==NULL)
        return NULL;

	return strcpy(unProtocolo,unServidor->protocolo);
}


/**************************************************************************************/

char *GetIp(const Servidor *unServidor)
{
     char* unaIP;
     
	if((unaIP=malloc(strlen(unServidor->ip)+1))==NULL)
        return NULL;

	return strcpy(unaIP,unServidor->ip);
}


/**************************************************************************************/

char *GetPuerto(const Servidor *unServidor)
{
     char* unPuerto;
     
	if((unPuerto=malloc(strlen(unServidor->puerto)+1))==NULL)
        return NULL;

	return strcpy(unPuerto,unServidor->puerto);
}


/**************************************************************************************/


void Destruir(Servidor *unServidor)
{
    free(unServidor->ip);
	free(unServidor->protocolo);
	free(unServidor->puerto);
	free(unServidor);
}

/**************************************************************************************/